
 <script type="text/javascript">

 RED.nodes.registerType('baidu-translator',{ 
	category: 'function',
	color: '#33CCFF', 
	defaults: { 
		name: {value:""},
		url:{value:"http://api.fanyi.baidu.com/api/trans/vip/translate",required:true},
		method:{value:"GET"},
		from:{value:"en"},
		to:{value:"zh"},
		appid:{value:"",required:true},
		key:{value:"",required:true} }, 
	inputs:1, outputs:1, icon: "file.ico", 
	label: function() { return this.name||"baidu-translator"; } });

</script>



<script type="text/x-red" data-template-name="baidu-translator"> 
<div class="form-row"> 
<label for="node-input-name">
<i class="icon-tag"></i> name
</label> 
<input type="text" id="node-input-name" placeholder="Name">
	</div>
<div class="form-row"> 
<label for="node-input-url">
<i class="icon-tag"></i> url
</label>
<input type="url" id="node-input-url">
</div>

<div class="form-row"> 

<label for="node-input-method"><i class="fa fa-tasks"></i>method</label>
        <select type="text" id="node-input-method">
        <option value="GET">GET</option>
        <option value="POST">POST</option>
        </select>
</div>
<div class="form-row"> 

<label for="node-input-from"><i class="fa fa-tasks"></i>from</label>
        <select type="text" id="node-input-from">
        <option value="auto">auto</option>
        <option value="en">English</option>
        <option value="zh">Mandarin</option>
        <option value="yue">Cantonais</option>
        <option value="jp">Japanese</option>
        <option value="kor">Korean</option>
        <option value="fra">French</option>
        <option value="wyw">Magical Chinese</option>
        </select>
</div>
<div class="form-row"> 

<label for="node-input-to"><i class="fa fa-tasks"></i>to</label>
        <select type="text" id="node-input-to">
        <option value="en">English</option>
        <option value="zh">Mandarin</option>
        <option value="yue">Cantonais</option>
        <option value="jp">Japanese</option>
        <option value="kor">Korean</option>
        <option value="fra">French</option>
        <option value="wyw">Magical Chinese</option>
        </select>
</div>
<div class="form-row"> 

<label for="node-input-appid">
<i class="icon-tag"></i> appid
</label>
<input type="text" id="node-input-appid">
</div>
<div class="form-row"> 
<label for="node-input-key">
<i class="icon-tag"></i> key
</label>
<input type="password" id="node-input-key">


	</div> 
	</script>


<script type="text/x-red" data-help-name="baidu-translator">
 <p>
 	url: 调用的API的url <br>
 	method: 发送请求的方法，默认为GET方法<br>
 	from : 翻译的源语言 , 默认为en 英语<br>
 	to:翻译的目标语言 , 默认为 zh<br>
 	appid: 在百度翻译官网上申请得到的appid<br>
 	key: 在百度翻译官网上取得的密钥<br>

 	输入:msg.message<br>
 	输出:msg.trans_result:{
 	   from:"srcLanguage",
 	   to:"desLanguage",
 	   src:"messageInput",
 	   dst:"messageOutput"
 	}
 </p> 

 </script>

